package com.promis.widget.mediapicker;

import android.content.Context;
import android.content.Intent;

import com.promis.widget.mediapicker.entity.ImageParcelable;
import com.promis.widget.mediapicker.manager.ImagePreviewListener;
import com.promis.widget.mediapicker.manager.ImagePreviewManager;
import com.promis.widget.mediapicker.ui.ImagePreviewActivity;

import java.util.List;

/**
 * Created by jidanbo on 2018/3/26.
 */

public class ImagePreviewApi {

    public static Builder with(Context context) {
        Builder builder = new Builder(context);
        return builder;
    }

    public static class Builder {
        private Context context;

        public Builder(Context context) {
            this.context = context;
        }

        public Builder position(int position) {
            ImagePreviewManager.getInstance().setSelectPosition(position);
            return this;
        }

        public Builder list(List<ImageParcelable> imageList) {
            ImagePreviewManager.getInstance().setImageList(imageList);
            return this;
        }

        public Builder subscribe(ImagePreviewListener listener) {
            ImagePreviewManager.getInstance().setMediaPreviewListener(listener);
            return this;
        }

        public void open() {
            Intent intent = new Intent(this.context, ImagePreviewActivity.class);
            this.context.startActivity(intent);
        }
    }
}
